package com.gkd.dao;

import com.gkd.mapper.DepartmentMapper;
import com.gkd.mapper.EmployeeMapper;
import com.gkd.pojo.Department;
import com.gkd.service.DepartmentService;
import com.gkd.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class DepartmentDao {

    @Autowired
    DepartmentService departmentService;
    @Autowired
    EmployeeService employeeService;

    public Map<Integer,Department> fdm = new HashMap<>();


//    private static Map<Integer, Department> departments = null;

//    static {
//        departments = new HashMap<Integer,Department>();
//
//        departments.put(1,new Department(1,"教学部"));
//        departments.put(2,new Department(2,"市场部"));
//        departments.put(3,new Department(3,"教研部"));
//        departments.put(4,new Department(4,"运营部"));
//        departments.put(5,new Department(5,"后勤部"));
//
//    }
    public Map<Integer,Department> departmentMap(){
        List<Department> ds =departmentService.queryDepartmentAll();
//        Map<Integer,Department> dm = new HashMap<>();
        for(int i =0; i<ds.size();i++){
            fdm.put(ds.get(i).getId(),ds.get(i));
        }
        return fdm;
    }

    public Collection<Department> getDepartment(){
        return fdm.values();
    }

//    public Collection<Department> getDepartment(){
//        return departments.values();
//    }

    public Department getDepartmentById(Integer id){
        return fdm.get(id);
    }
}
